package com.wll.ppjoke.utils;

import android.annotation.SuppressLint;
import android.os.Looper;
import android.widget.Toast;

import androidx.arch.core.executor.ArchTaskExecutor;

import com.wll.libcommon.AppGlobals;

/**
 * created by detachment on 2020/11/17
 */
public class ToastUtils {
    @SuppressLint("RestrictedApi")
    public static void showToast(String s) {
        //showToast几个可能会出现在异步线程调用
        if (Looper.myLooper() == Looper.getMainLooper()) {
            Toast.makeText(AppGlobals.getApplication(), s, Toast.LENGTH_SHORT).show();
        } else {
            ArchTaskExecutor.getMainThreadExecutor().execute(() -> Toast.makeText(AppGlobals.getApplication(), s, Toast.LENGTH_SHORT).show());
        }
    }
}
